<?php

/**
 * Created by PhpStorm.
 * User: Rivaille
 * Date: 2019/4/26
 * Time: 下午2:14
 */

namespace App\Services;

use Carbon\Carbon;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use InvalidArgumentException;
use Symfony\Component\HttpFoundation\File\UploadedFile;

class ValidatorService
{

    /**
     * @var mixed
     */
    private $data;

    /**
     * 自定义的验证
     *
     * @var array
     */
    private $extends = [
        'cellphone',
        'file',
        'before_or_equal',
        'after_or_equal',
    ];

    public static function paramsValidate($params,$validate)
    {
        $validator = Validator::make($params, $validate);
        if ($validator->errors()->toArray()){
            echo json_encode([
                'code' => 500,
                'msg' => '参数错误',
                'data' => $validator->errors(),
            ]);die;
        }
    }
}
